var merge = require('webpack-merge')

const DEVELOPMENT = 'development'
const TEST = 'test'
const PRERELEASE = 'preRelease'
const PRODUCTION = 'production'

// dev-server
let defaultEnvironment = {
  dir: 'dist',
  baseWebUrl: '"http://www.dev.com"',
}
let NODE_ENV = '"production"'
let environment = defaultEnvironment
switch (process.env.NODE_ENV) {
  case DEVELOPMENT:
    // 开发
    environment.dir = 'dist-dev'
    NODE_ENV = '"development"'
    break
  case TEST:
    // 测试
    environment.dir = 'dist-test'
    environment.baseWebUrl = '"http://www.test.com"'
    break
  case PRERELEASE:
    // 预发布
    environment.dir = 'dist-pre'
    environment.baseWebUrl = '"http://www.pre.com"'
    break
  case PRODUCTION:
    // 生产
    environment.dir = 'dist-prod'
    environment.baseWebUrl = '"http://www.prod.com"'
    break
  default:
}

module.exports = merge(process.env, {
  NODE_ENV: NODE_ENV,
  ...environment
})
